package com.maptool.config;

import android.graphics.Color;

import com.esri.arcgisruntime.geometry.Geometry;
import com.esri.arcgisruntime.geometry.GeometryType;
import com.esri.arcgisruntime.mapping.view.Graphic;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.SketchStyle;
import com.esri.arcgisruntime.symbology.SimpleFillSymbol;
import com.esri.arcgisruntime.symbology.SimpleLineSymbol;
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;

public class MapConfig {


    /**
     * 不规则图形修边的时候出现多个地块中底部弹出选择框的中名字
     */
    public static String clipName = "图斑：";

    //面的颜色；33代表透明度
    public static String polygonColor = "#33e97676";


    //高亮展示信息
    public static void highlightGeometry(Geometry geometry, GraphicsOverlay mHighlightGraphicsOverlay) {
        //单个图斑高亮显示操作
        SimpleMarkerSymbol markSymbolTemp = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 10);
        SimpleLineSymbol lineSymbolTemp = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.RED, 2);
        SimpleFillSymbol fillSymbolTemp = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.parseColor(polygonColor), lineSymbolTemp);
        //存在点线面三种类型
        GeometryType geometryType = geometry.getGeometryType();
        Graphic graphic = null;
        if (geometryType == GeometryType.POINT) {
            graphic = new Graphic(geometry, markSymbolTemp);
        } else if (geometryType == GeometryType.POLYLINE) {
            graphic = new Graphic(geometry, lineSymbolTemp);
        } else if (geometryType == GeometryType.POLYGON) {
            graphic = new Graphic(geometry, fillSymbolTemp);
        }
        mHighlightGraphicsOverlay.getGraphics().add(graphic);
    }


    public static SketchStyle getTtansparentSketchStyle() {
        SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 10);
        SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.DASH_DOT_DOT, Color.TRANSPARENT, 1.5f);
        SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.parseColor(polygonColor), lineSymbol);
        SketchStyle mainSketchStyle = new SketchStyle();
        mainSketchStyle.setVertexSymbol(simpleMarkerSymbol);
        mainSketchStyle.setLineSymbol(lineSymbol);
        mainSketchStyle.setFillSymbol(simpleFillSymbol);
        return mainSketchStyle;
    }

    public static SketchStyle getSketchStyle() {
        SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 10);
        SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.DASH_DOT_DOT, Color.GREEN, 1.5f);
        SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.parseColor(polygonColor), lineSymbol);
        SketchStyle mainSketchStyle = new SketchStyle();
        mainSketchStyle.setVertexSymbol(simpleMarkerSymbol);
        mainSketchStyle.setLineSymbol(lineSymbol);
        mainSketchStyle.setFillSymbol(simpleFillSymbol);
        return mainSketchStyle;
    }


    public static void clearGraphicsOverlay(GraphicsOverlay mHighlightGraphicsOverlay) {
        mHighlightGraphicsOverlay.getGraphics().clear();
    }
}
